<?php TPL::output('admin/global/header.tpl.htm'); ?>

<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->

<!-- main -->
<div id="main-content">
	<div class="clear"></div>
	<div class="content-box">
		<div class="content-box-header">
			<h3><?php echo $this->crumb['last']['name']; ?></h3>
			<ul class="content-box-tabs">
				<li><a href="#tab1" class="default-tab current">管理专题</a></li>
				<li><a href="admin/feature/list/" class="">专题列表</a></li>
				<li><a href="#tab2">添加专题</a></li>
			</ul>
			<div class="clear"></div>
		</div>
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">
				<?php if($this->list){ ?>
				<div id="addtxt" class="add_C" style="line-height:23px;">
				<?php foreach($this->list as $key => $val){ ?>
				<span id="<?php echo $val['topic_id']; ?>" val="tag"><a rel="<?php echo $val['topic_id']; ?>" target="_blank" href="topic/<?php echo $val['url_token']; ?>"><?php echo $val['topic_title']; ?></a><a href="javascript:;" onClick="ajax_request(G_BASE_URL + '/admin/feature/delete_topic_ajax/feature_id-<?php echo $this->feature['id']; ?>__topic_id-<?php echo $val['topic_id']; ?>');" title="删除标签">[x]</a></span>
				<?php } ?>
				</div>
				<?php } ?>
				<form id="_save_form" action="admin/feature/add_topic_ajax/feature_id-<?php echo $this->feature['id']; ?>" method="post" style="margin-top:10px;">
					<p>
						<label>添加标签：&nbsp;&nbsp;
						<input class="text-input" style="width:120px;" type="text" id="topic" name="topic" value=""/>
						<input type="hidden" id="topic_id" name="topic_id" value=""/>
						&nbsp;&nbsp;
						<input class="button" type="button" onClick="ajax_post($('#_save_form'), _form_process);" value="添加" />
						</label>
					</p>
				</form>
			</div>
			<div class="tab-content" id="tab2" style="display: none;">
				<h3>添加专题</h3>
				<form id="_add_form" action="admin/feature/save_ajax/" method="post">
					<p>
						<label>专题标题：</label>
						<input type="text" value="" class="text-input medium-input" name="title">
					</p>
					<p>
						<label>专题描述：</label>
						<input id="description" type="text" value="" class="text-input medium-input" name="description">
					</p>
					<p>
						<label>专题图标：</label>
						<input name="icon" class="upload-input" type="file">
						<br />
						<small>(支持上传图片类型：jpg,jpeg,gif,png)</small> </p>
					<p>
						<input class="button" type="button" onClick="ajax_post($('#_add_form'), _form_process);" value="添加新专题" />
					</p>
					</label>
					</p>
				</form>
			</div>
		</div>
		<div class="clear"></div>
		<div id="notf_tip" style="display:none;" class="notification png_bg"> <a href="javascript:;" class="close"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/cross_grey_small.png" alt="关闭" /></a>
			<div id="notf_cont"></div>
		</div>
	</div>

<!-- footer -->
<?php TPL::output('admin/global/footer.tpl.htm'); ?>
<!-- footer -->

</div>
<!-- main -->

</div>

<script>

$("#topic").keyup(function(){
	$("#topic").focus();
});

$("#topic").autocomplete(G_BASE_URL + "/search/ajax/search/type-topic_add", {
    width: 134,
	multiple: false,
	dataType: "json",
	parse: function(data) {
		var flag = 0;
		  return $.map(data, function(row) {
		  		if(flag == 1)
				{
				  return {
					  data: row,
					  value: row.sno,
					  result: row.name
				  }
				}
				flag = 1;
		  });
		
	},
	formatItem: function(item) {
		return item.name + "\n";
	}
}).result(function(event, data, formatted) {
	$('#topic_id').val(formatted);
	ajax_post($('#_save_form'), _form_process);
});

</script>

</body>
</html>
